package io.renren.controller;

import java.util.List;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.entity.EmpBlacklistEntity;
import io.renren.service.EmpBlacklistService;
import io.renren.utils.PageUtils;
import io.renren.utils.Query;
import io.renren.utils.R;


/**
 * 员工黑名单管理
 * 
 * @author zhangheng
 * @email zh_123shmily@163.com
 * @date 2017-07-10 17:32:49
 */
@RestController
@RequestMapping("empblacklist")
public class EmpBlacklistController {
	@Autowired
	private EmpBlacklistService empBlacklistService;
	
	/**
	 * 列表
	 */
	@RequestMapping("/list")
	@RequiresPermissions("empblacklist:list")
	public R list(@RequestParam Map<String, Object> params){
		//查询列表数据
        Query query = new Query(params);

		List<EmpBlacklistEntity> empBlacklistList = empBlacklistService.queryList(query);
		int total = empBlacklistService.queryTotal(query);
		
		PageUtils pageUtil = new PageUtils(empBlacklistList, total, query.getLimit(), query.getPage());
		
		return R.ok().put("page", pageUtil);
	}
	
	
	/**
	 * 信息
	 */
	@RequestMapping("/info/{id}")
	@RequiresPermissions("empblacklist:info")
	public R info(@PathVariable("id") Integer id){
		EmpBlacklistEntity empBlacklist = empBlacklistService.queryObject(id);
		
		return R.ok().put("empBlacklist", empBlacklist);
	}
	
	/**
	 * 保存
	 */
	@RequestMapping("/save")
	@RequiresPermissions("empblacklist:save")
	public R save(@RequestBody EmpBlacklistEntity empBlacklist){
		empBlacklistService.save(empBlacklist);
		
		return R.ok();
	}
	
	/**
	 * 修改
	 */
	@RequestMapping("/update")
	@RequiresPermissions("empblacklist:update")
	public R update(@RequestBody EmpBlacklistEntity empBlacklist){
		empBlacklistService.update(empBlacklist);
		
		return R.ok();
	}
	
	/**
	 * 删除
	 */
	@RequestMapping("/delete")
	@RequiresPermissions("empblacklist:delete")
	public R delete(@RequestBody Integer[] ids){
		empBlacklistService.deleteBatch(ids);
		
		return R.ok();
	}

	/**
	 * 保存
	 */
	@RequestMapping("/unlock")
	@RequiresPermissions("empblacklist:save")
	public R unlock(@RequestBody EmpBlacklistEntity empBlacklist){
		empBlacklistService.unlock(empBlacklist);

		return R.ok();
	}
	
}
